package com.oocl.o2o.client.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import com.oocl.o2o.client.entity.Merchant;
import com.oocl.o2o.client.service.AdvertisementService;
import com.oocl.o2o.client.service.MerchantService;
import com.oocl.o2o.client.vo.AdvertisementVO;
import com.oocl.o2o.client.vo.OrderItemVO;

/**
 * @description: 
 * @author  XIEMI2
 * @date Aug 12, 2017 5:15:12 PM
 * @version 1.0
 */
@Controller
public class CustomerAction {

	@Resource
	private MerchantService merchantService;
	@Resource
	private AdvertisementService advertisementService;
	
	@GetMapping("/home")
	public String home(HttpServletRequest request){
		List<Merchant> merchants = merchantService.getAllPassMerchantsFromA();
		List<AdvertisementVO> advertisementVOs = advertisementService.findAll();
		request.setAttribute("advertisementVOs", advertisementVOs);
		request.setAttribute("merchants", merchants);
		
		
		return "home";
	}
	
	@GetMapping("/login")
	public String login(){
		return "login";
	}
	
	@RequestMapping("/register")
	public String register(){
		return "register";
	}
	
	@GetMapping("/logout")
	public String logout(HttpSession session){
		session.setAttribute("customer", null);
		return "redirect: home";
	}
	
}


